package com.xiaoran.springboot3.controller;

import com.xiaoran.springboot3.bean.User;
import com.xiaoran.springboot3.exception.UserToManException;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;

import java.util.Arrays;
import java.util.List;

@Controller
public class TableCtroller {

    @GetMapping("/basic_table")
    public String basic_table(){
        return "table/basic_table";
    }
    @GetMapping("/responsive_table")
    public String responsive_table(){
        return "table/responsive_table";
    }
    @GetMapping("/dynamic_table")
    public String dynamic_table(Model model){
       List<User> list= Arrays.asList(new User("张三","18"),
                new User("李四","14"),
                new User("王五","250"),
                new User("小冉","123"));
       model.addAttribute("list",list);
       if (list.size()>3){
           throw new  UserToManException();
       }
        return "table/dynamic_table";
    }
    @GetMapping("/editable_table")
    public String  editable_table(){
        return "table/editable_table";
    }


}
